import pygame
import draw
from defs import *
class Menu():
	def __init__(self,pong):
		self.pong = pong
		self.option = None
		self.done = False
		self.clock = pygame.time.Clock()
		
		self.draw = draw.Draw(pong.draw.screen)
		self.draw.setColors(white,black)
		
	def chooseOption(self):
		
		
		if self.option == 'play':
			self.pong.reset()
			self.pong.done = False
			self.pong.start()
			self.option = None
			self.draw = draw.Draw(self.pong.draw.screen)
			self.draw.setColors(white,black)
		elif self.option == 'ach':
			self.showAchivements()
			self.option = None
		elif self.option == 'quit':
			self.done = True
			self.option = None
			
	def showAchivements(self):
		print "ACH!"

	def start(self):
		self.draw.update()
        
		while not self.done:    
			
			self.processInput()
			
			# ----- Begin Drawing Something -----
			self.draw.displayMainMenu()
			self.draw.update()
			# ----- End Drawing Something -----

			self.chooseOption()
			# Limit to fps frames per second
			self.clock.tick(fps)
	
	def processInput(self):
		events = pygame.event.get()
		for event in events:
			if event.type == pygame.QUIT:
				self.done = True
				break

			if event.type == pygame.KEYDOWN:
				self.processPressedKey(event.key)

            
	def processPressedKey(self, key):
		if key == pygame.K_s:
			self.option = 'play'
		if key == pygame.K_a:
			self.option = 'ach'
		if key == pygame.K_ESCAPE:
			self.option = 'quit'
		
